Add default User-Agent for integration HTTP requests#46
Open
TheRealAgentK wants to merge 3 commits into
Open
Conversation
Coverage —
|
| File | Stmts | Miss | Cover | Missing |
|---|---|---|---|---|
src/autohive_integrations_sdk/__init__.py |
2 | 0 | 100% | |
src/autohive_integrations_sdk/integration.py |
389 | 0 | 100% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds SDK-level
User-Agenthandling for integration HTTP requests made throughExecutionContext.fetch().Default behavior
When an integration does not provide a
User-Agent, the SDK now sends a versioned Autohive default instead of relying on aiohttp's default:When the request is made from a registered integration handler, the SDK also includes the integration identity from
config.json:Example:
Integration name/version values are sanitized for safe
User-Agentproduct tokens.Custom User-Agent support
Adds a convenience
user_agentargument tocontext.fetch():Existing header-based usage is still supported:
Precedence is:
headers["User-Agent"]/headers["user-agent"]user_agent="..."This means integrations that already set a custom
User-Agentdo not need to change and keep their existing behavior.Context identity handling
The integration identity is applied only while a handler is executing and then restored, so reusing an
ExecutionContextacross integrations does not leak the previous integration identity.CI/test dependency note
Constrains the test extra to
aiohttp<3.13.4because the currentaioresponsesrelease is incompatible with neweraiohttpClientResponseconstructor changes in CI. The SDK runtime dependency remains unconstrained (aiohttp).Docs
User-Agentbehavior and the newuser_agentargument in the manual docs.pdoc.Testing
.venv/bin/python -m pytest tests/ -v.venv/bin/python -m pytest tests/ -v --cov=autohive_integrations_sdk --cov-report=term-missing83 passed100% coveragegit diff --check